<?php
class static_message
{
    protected static $api_url = "http://message.i-che.net/ReceiveMessageServlet";
    protected static $api_key = "jinkedaikuanwangdiang123456";
    
    public static function send($mobile, $message,$type = null) {
        $data["clientId"] = "6";
        $data["time"] = date("Y-m-d H:i:s");
        $data["message"] = base64_encode($message);
        $data["telNum"] = $mobile;
        $data["encrypt"] = md5(self::$api_key.$data["time"].$data["clientId"].$data["telNum"].$data["message"]);
        $data['signature'] = '01';
        $result = static_function::http_curl(self::$api_url,$data);
        //$result = '000';
        if($result  == '000') {
            if ($type) {
                $his['type'] = $type;
                $his['mobile'] = $mobile;
                model_hismessage::getInstance()->insert($his);
            }
            return true;
        } else {
            static_function::write_log("短信发送失败\t".$mobile."\t".$message."\t");
            return false;
        }
    }

    //生成随机验证码
    public static function rand_code() {
        return mt_rand(100000, 999999);
    }
}
?>
